import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '@/views/index/index'
import Api from '@/views/api'
import Login from '@/views/login/index.vue';
import Errata from '@/views/errata/index.vue';
import Layout from '@/views/layout/index.vue';
import Writing from '@/views/writing/index.vue';
import Knowledgebase from '@/views/knowledgebase/index.vue';
import Loginframs from '@/views/loginframs/index.vue';


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Index,
    redirect: '/index',
  },
  {
    path: '/api',
    component: Api
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/errata',
    name: '勘误',
    component: Errata
  },
  {
    path: '/layout',
    name: '智能排版',
    component: Layout
  },
  {
    path: '/writing',
    name: '智能写作',
    component: Writing
  },
  {
    path: '/knowledgebase',
    name: '内部知识库',
    component: Knowledgebase
  },
  {
    path: '/loginframs',
    name: 'ca登录',
    component: Loginframs
  },
]

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  mode: 'hash',
  routes
})

export default router
